<template>
  <el-container class="home-container">
    <!-- 头部 -->
    <el-header class="neu">
      <div>
        <span >东软云医院后台管理系统</span>
      </div>
      <el-button type="info" @click="logout">退出</el-button>
    </el-header>
    <!-- 主体容器 -->
    <el-container>
      <!-- 侧边栏 -->
      <el-aside :width="isCollapse ? '64px' : '200px'">
        <!-- 折叠菜单栏 -->
        <div class="toggle-btn" @click="toggleCollapse">|||</div>
        <!-- 侧边栏菜单 -->
        <!-- <el-menu
          background-color="#606266"
          text-color="#fff"
          active-text-color="#ffd04b"
          unique-opened
          :collapse="isCollapse"
          :collapse-transition="false"
          router
          :default-active="activePath"
        > -->
          <!-- 一级菜单 -->
          <!-- <el-submenu
            :index="item.id + ''"
            v-for="item in menuList"
            :key="item.id"
          >
            <template slot="title">
              <i :class="icons[item.id]"></i>
              <span>{{ item.authName }}</span>
            </template> -->
            <!-- 二级菜单 -->
            <!-- <el-menu-item
              :index="subItem.path + ''"
              v-for="subItem in item.children"
              :key="subItem.id"
              @click="navState(subItem.path)"
            > -->
              <!-- 二级菜单的模板 -->
              <!-- <template slot="title">
                <i class="el-icon-menu"></i>
                <span>{{ subItem.authName }}</span>
              </template>
            </el-menu-item>
          </el-submenu>
        </el-menu> -->
         <el-menu
                background-color="#606266"
                text-color="#fff"
                active-text-color="#409fff" unique-opened :collapse="isCollapse" :collapse-transition="false" router :default-active="activePath">
          <el-submenu index="1">
            <template slot="title"><i class="el-icon-s-ticket"></i>挂号收费</template>
            <el-menu-item index="1-4-1"><i class="el-icon-loading"></i>现场挂号</el-menu-item>
            <el-menu-item index="1-4-2"><i class="el-icon-loading"></i>收费</el-menu-item>
            <el-menu-item index="1-4-3"><i class="el-icon-loading"></i>退号</el-menu-item>
            <el-menu-item index="1-4-4"><i class="el-icon-loading"></i>退费</el-menu-item>
            <el-menu-item index="1-4-5"><i class="el-icon-loading"></i>发票补打</el-menu-item>
            <el-menu-item index="1-4-6"><i class="el-icon-loading"></i>发票重打</el-menu-item>
            <el-menu-item index="1-4-7"><i class="el-icon-loading"></i>日结</el-menu-item>
            <el-menu-item index="1-4-8"><i class="el-icon-loading"></i>费用查询</el-menu-item>
          </el-submenu>
          <el-submenu index="2">
            <template slot="title"><i class="el-icon-s-finance"></i>门诊医生</template>
            <el-menu-item index="1-4-1"><i class="el-icon-loading"></i>看诊</el-menu-item>
             <el-menu-item index="1-4-2"><i class="el-icon-loading"></i>医技模板</el-menu-item>
              <el-menu-item index="1-4-3"><i class="el-icon-loading"></i>西药处方模板</el-menu-item>
          </el-submenu>
          <el-submenu index="3">
            <template slot="title"><i class="el-icon-s-custom"></i>系统管理</template>
            <el-menu-item index="constantitem" @click="navState('constantitem')" ><i class="el-icon-loading"></i>常数管理</el-menu-item>
            <el-menu-item index="department"  @click="navState('department')"><i class="el-icon-loading"></i>科室管理</el-menu-item>
            <el-menu-item index="usermanager" @click="navState('usermanager')"><i class="el-icon-loading"></i>用户管理</el-menu-item>
            <el-menu-item index="registlevel" @click="navState('registlevel')"><i class="el-icon-loading" ></i>挂号等级管理</el-menu-item>
            <el-menu-item index="settlecategory" @click="navState('settlecategory')"><i class="el-icon-loading"></i>结算管理</el-menu-item>
            <el-menu-item index="1-4-5"><i class="el-icon-loading"></i>疾病管理</el-menu-item>
            <el-menu-item index="scheduling" @click="navState('scheduling')"><i class="el-icon-loading"></i>医生排班管理</el-menu-item>
          </el-submenu>
   
    </el-menu>
      </el-aside>
      <!-- 主体 -->
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>
<script>
export default {
  data() {
    return {
      //左侧菜单的数据
      menuList: null,
      icons: {
        "125": "iconfont icon-user",
        "103": "iconfont icon-tijikongjian",
        "101": "iconfont icon-shangpin",
        "102": "iconfont icon-danju",
        "145": "iconfont icon-baobiao"
      },
      isCollapse: false,
      activePath: ''
    };
  },
  created() {
    // this.getMenuList();
    //从sessionStorage中获取到activePath并赋值给属性activePath
    this.activePath = window.sessionStorage.getItem('activePath');
  },
  methods: {
    logout() {
      //清除sessionStorage中的数据(token)
      window.sessionStorage.clear();
      this.$router.push("/login");
    },
    // async getMenuList() {
    //   //需要向后台发送axios请求获取数组
    //   const { data: res } = await this.$http.get("menus");
    //   //判断数据是否获取到了
    //   if (res.meta.status !== 200) return this.$message.error(res.meta.msg);
    //   this.menuList = res.data;
    //   console.log(res);
    // },
    toggleCollapse() {
      //处理菜单得折叠效果
      this.isCollapse = !this.isCollapse;
    },
    //激活状态
    navState(path) {
      window.sessionStorage.setItem("activePath", path);
    }
  }
};
</script>

<style lang="less" scoped>
.home-container {
  height: 100%;
}
.el-header {
  background-color: #303133;
  display: flex;
  justify-content: space-between;
  padding-left: 0;
  align-items: center;
  color: #ffffff;
  font-size: 20px;
  > div {
    display: flex;
    align-items: center;
    span {
      margin-left: 15px;
    }
  }
}
.el-aside {
  background-color: #606266;
  .el-menu {
    border-right: none;
  }
}
.el-main {
  background-color: #dcdfe6;
}
.iconfont {
  margin-right: 12px;
}
.toggle-btn {
  background-color: #909399;
  font-size: 10px;
  color: #ffffff;
  letter-spacing: 2px;
  text-align: center;
  line-height: 22px;
  cursor: pointer;
}

.neu{
  background-color: greenyellow;
}
</style>
